
#include<stdio.h>
#include<errno.h>
int recv_msg(int sockfd, char buff[], int len){
	int n;
	while(1){
		n = read(sockfd, buff, len);
		if (n < 0){
			if( n == EINTR )
				continue;
			return n;
		}
		return n;
	}

}

int write_msg(int sockfd, void* buff,int length){

	int done = length;
	while ( 1 ) {
		done = write(sockfd, buff, length);
		if (done != length)
			if( errno == EINTR)
				continue;
			else{
				printf("fail to write!");
				return -1;
			}
		return done;
	}
}
